﻿@{
    Layout = "~/Areas/Admin/Views/Shared/_LoginLayout.cshtml";
}

<link rel="stylesheet" href="css/logo-style.css">
<div class="logo" id="reset" data-bound="true">
    <article>
        <br /><br />
        <p id="text">Code By LuDragon.</p>      
    </article>
</div>
<ul class="login-list">
    <li><input type="text" placeholder="请输入用户名" name="userName" id="userName"></li>
    <li><input type="password" placeholder="请输入密码" name="password" id="pwd"></li>
    <li><input type="text" placeholder="请输入验证码" id="code"><span class="yzm2"><img src="~/Content/login/img/yzm.jpg" alt=""></span></li>
    <li><a class="btn" id="btnLogin">登 录</a></li>
    <li class="tar"><a href="/User/ForgetPassword">忘记密码？</a></li>
</ul>
<script src="~/Content/js/logo.js"></script>
<script>
    //防止session过期重复嵌套
    if (window != top) {
        top.location.href = location.href;
    }
    //登录
    $("#btnLogin").click(function () {
        if ($("#userName").val() && $("#pwd").val()) {
            var pwd = $.md5($("#pwd").val());
            dialog.loading();
            $.ajax({
                url: "Login/Login", type: "post",
                data: { "userName": $("#userName").val(), "password": pwd },
                success: function (result) {
                    dialog.closeLoading();
                    var data = JSON.parse(result);
                    if (data.Code == 200) {
                        localStorage.setItem("loginInfo", JSON.stringify(data.Data));
                        location.href = "/Index/Index";
                    } else {
                        dialog.info("用户名或密码错误");
                    }
                },
                error: function () {
                    dialog.closeLoading();
                    dialog.prompt("网络请求失败");
                }
            });
        } else {
            dialog.info("请输入用户名和密码");
        }
    });
    document.onkeydown = (function (e) {
        if (e.keyCode == 13) {
            $("#btnLogin").click();
        }
    });
</script>
